package leetcode.每日一题;

import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2021/12/31 13:22
 * @description：https://leetcode-cn.com/problems/perfect-number/
 */
public class 完美数 {
    @Test
    public void test() {
        Solution solution = new Solution();
        System.out.println(solution.checkPerfectNumber(8128));
    }


    class Solution {
        public boolean checkPerfectNumber(int num) {
            if (num == 1) return false;
            int ans = 1;
            for (int i = 2; i <= num / i; i++) {
                if (num % i == 0) {
                    ans += i;
                    ans += num / i;
                }
            }
            return ans == num;
        }
    }
}
